package model

import (
	"manager/model/entity"
)

// MallLinkCreateRequest 创建现场数据
type MallLinkCreateRequest struct {
	Name string `json:"name"`

	Desc string `json:"desc"`

	Price int `json:"price"`

	ImageUrl string `json:"image_url"`

	Url string `json:"url"`

	Weight int `json:"weight"`

	UpdatedAt int64 `json:"updated_at"`
}

// MallLinkUpdateRequest 更新现场数据
type MallLinkUpdateRequest struct {
	Id int64 `json:"id"`

	Name *string `json:"name"`

	Desc *string `json:"desc"`

	Price *int `json:"price"`

	ImageUrl *string `json:"image_url"`

	Url *string `json:"url"`

	Weight *int `json:"weight"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// MallLinkListRequest 列表现场数据
type MallLinkListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	Name *string `json:"name"`

	Desc *string `json:"desc"`

	Price *int `json:"price"`

	ImageUrl *string `json:"image_url"`

	Url *string `json:"url"`

	Weight *int `json:"weight"`

	UpdatedAt *int64 `json:"updated_at"`
}

// MallLinkListResponse 列表回包数据
type MallLinkListResponse struct {
	Total int             `json:"total"`
	List  []*MallLinkInfo `json:"list"`
}

// MallLinkInfoRequest 列表现场数据
type MallLinkInfoRequest struct {
	Id int64 `json:"id"`

	Name *string `json:"name"`

	Desc *string `json:"desc"`

	Price *int `json:"price"`

	ImageUrl *string `json:"image_url"`

	Url *string `json:"url"`

	Weight *int `json:"weight"`

	UpdatedAt *int64 `json:"updated_at"`
}

// MallLinkInfo 详细数据
type MallLinkInfo struct {
	Id int64 `json:"id"`

	Name string `json:"name"`

	Desc string `json:"desc"`

	Price int `json:"price"`

	ImageUrl string `json:"image_url"`

	Url string `json:"url"`

	Weight int `json:"weight"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// MallLinkDeleteRequest 删除现场数据
type MallLinkDeleteRequest struct {
	Id int64 `json:"id"`
}

// MallLinksEntityToDto entity数据转换
func MallLinksEntityToDto(mallLinks []*entity.MallLink) []*MallLinkInfo {
	out := make([]*MallLinkInfo, 0, len(mallLinks))
	for _, c := range mallLinks {
		out = append(out, MallLinkEntityToDto(c))
	}
	return out
}

// MallLinkEntityToDto entity数据转换
func MallLinkEntityToDto(e *entity.MallLink) *MallLinkInfo {
	return &MallLinkInfo{

		Id: e.Id,

		Name: e.Name,

		Desc: e.Desc,

		Price: e.Price,

		ImageUrl: e.ImageUrl,

		Url: e.Url,

		Weight: e.Weight,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
